package net.minecraft.src;

import java.util.Map;
import java.util.Random;
import java.math.*;
import net.minecraft.client.Minecraft;

	

public class mod_testmod extends BaseMod {
	public static Block oreEbony = new ebonyOre(170).setUnlocalizedName("ebony ore").setHardness(10).setResistance(7);
	public static Item shardEbony = new Item(171).setUnlocalizedName("ebony shard").setCreativeTab(CreativeTabs.tabMisc);
	public static Block novaBomb = new BlockNovaBomb(172).setHardness(1).setCreativeTab(CreativeTabs.tabMisc).setUnlocalizedName("NovaBomb");
	public static Item leatherPink = new Item(173).setUnlocalizedName("leatherPink").setCreativeTab(CreativeTabs.tabMisc);
	public static Item beefCookedPurple = new ItemFood(174, 8, true).setUnlocalizedName("beefCookedPink").setCreativeTab(CreativeTabs.tabMisc);
	public static Item beefRawPurple = new ItemFood(175,3 ,true).setUnlocalizedName("beefRawPink").setCreativeTab(CreativeTabs.tabMisc);
	public static Block candyGrass = new BlockCandyGrass(176).setStepSound(Block.soundGrassFootstep).setHardness(1);
	public static CloseLands keld = new CloseLands(23); 
	public static Block candyLog = new BlockCandyLog(177).setUnlocalizedName("CandyLog").setHardness(2.0F);
	public static Block candyLeaves = new BlockCandyLeaves(178).setUnlocalizedName("CandyLeaves").setStepSound(Block.soundGrassFootstep).setHardness(0.2F);
	public static Item purpleMilk = new ItemPurpleMilk(179).setUnlocalizedName("milkPurple");
	public static Block candyWood = new Block(180, Material.wood).setUnlocalizedName("CandyWood").setCreativeTab(CreativeTabs.tabBlock).setHardness(2.0F).setResistance(5.0F);
	public static Block candySapling = new BlockCandySapling(181).setUnlocalizedName("CandySapling").setStepSound(Block.soundGrassFootstep);
	public static Item placeHolder = new ItemCandyBoneMeal(182).setCreativeTab(CreativeTabs.tabMisc).setUnlocalizedName("magicRag");
	public static Item placeHolderII = new ItemTeleporterPewPewPew(183).setUnlocalizedName("voidPearl").setCreativeTab(CreativeTabs.tabMisc);
	public static Item ebonyBoots = new ItemArmor(184, EnumArmorMaterial.DIAMOND, ModLoader.addArmor("ebony"), 3).setUnlocalizedName("voidBoots");
	public static Item ebonyLegs = new ItemArmor(185, EnumArmorMaterial.DIAMOND, ModLoader.addArmor("ebony"), 2).setUnlocalizedName("voidLegs");
	public static Item ebonyPlate = new ItemArmor(186, EnumArmorMaterial.DIAMOND, ModLoader.addArmor("ebony"), 1).setUnlocalizedName("voidPlate");
	public static Item ebonyMask = new ItemArmor(187, EnumArmorMaterial.DIAMOND, ModLoader.addArmor("ebony"), 0).setUnlocalizedName("voidMask");
	private KeyBinding key_fly = new KeyBinding("key.fly", 33);
	private KeyBinding key_creep = new KeyBinding("key.creep", 20);
	@Override
	public String getVersion() {
		// TODO Auto-generated method stub
		return "Version 1.0";
	}
	public boolean fly;
	public boolean creep;
	public int toFly = 0;
	//private Minecraft mc = Minecraft.getMinecraft();
	public boolean hasFlown = false;
	//ItemStack currentBoots = mc.thePlayer.inventory.armorInventory[3];
	int damageSheild = 0;
	int toPotion = 0;
	int wasPlate = 0;
	
	@Override
	public void load() {
		// TODO Auto-generated method stub
		ModLoader.registerBlock(oreEbony);
		ModLoader.addName(oreEbony, "Ebony Ore");
		ModLoader.addName(shardEbony, "Ebony Shards");
		ModLoader.registerBlock(novaBomb);
		ModLoader.addName(novaBomb, "Void Bomb");
		ModLoader.addRecipe(new ItemStack(novaBomb, 1), new Object[]{"WXW","XYX","WXW",'W', Item.diamond, 'X', Block.tnt, 'Y', mod_testmod.shardEbony});
		ModLoader.registerEntityID(EntityPurpleCow.class,  "Purple Cow", 53);
		ModLoader.registerEntityID(EntityRainbowSheep.class,  "Rainbow Sheep", 106);
		//ModLoader.registerEntityID(NovaBombPrimed.class, "Nova Bomb Primed", 106);
		//ModLoader.addSpawn(EntityPurpleCow.class, 0,0,0, EnumCreatureType.creature);
		ModLoader.addName(leatherPink, "Purple Leather");
		ModLoader.addName(beefCookedPurple, "Purple Steak");
		ModLoader.addName(beefRawPurple, "Raw Purple Beef");
		ModLoader.registerBlock(candyGrass);
		ModLoader.addName(candyGrass, "Candy Grass");
		ModLoader.addSmelting(beefRawPurple.itemID, new ItemStack(beefCookedPurple, 1), 0.4F);
		ModLoader.addBiome(keld);
		ModLoader.registerBlock(candyLog);
		ModLoader.addName(candyLog, "Magical Wood");
		ModLoader.registerBlock(candyLeaves);
		ModLoader.addName(candyLeaves, "Golden Leaves");
		ModLoader.addName(purpleMilk, "Purple Milk");
		ModLoader.registerBlock(candyWood);
		ModLoader.addName(candyWood, "Magical Wooden Planks");
		ModLoader.registerBlock(candySapling);
		ModLoader.addName(candySapling, "Candy Sapling");
		ModLoader.addShapelessRecipe(new ItemStack(candyWood, 4), new Object[] {candyLog});
		ModLoader.addName(ebonyBoots, "Void Boots");
		ModLoader.addName(ebonyLegs, "Void Legs");
		ModLoader.addName(ebonyPlate, "Void Plate");
		ModLoader.addName(ebonyMask, "Void Mask");
		ModLoader.setInGameHook(this, true, false);
		ModLoader.registerKey(this, this.key_fly, false);
		ModLoader.addLocalization("key.fly", "Void Boots Fly");
		ModLoader.registerKey(this, this.key_creep, false);
		ModLoader.addLocalization("key.creep", "Void Mask Creep");
		ModLoader.addName(placeHolderII, "Void Orb");
		ModLoader.addName(placeHolder, "Magic Rag");
		ModLoader.addRecipe(new ItemStack(Item.stick, 4), new Object[]{"   "," W "," W ",'W', mod_testmod.candyWood});
		ModLoader.addRecipe(new ItemStack(Item.stick, 4), new Object[]{"   ","W  ","W  ",'W', mod_testmod.candyWood});
		ModLoader.addRecipe(new ItemStack(Item.stick, 4), new Object[]{"   ","  W","  W",'W', mod_testmod.candyWood});
		ModLoader.addRecipe(new ItemStack(Item.stick, 4), new Object[]{" W "," W ","   ",'W', mod_testmod.candyWood});
		ModLoader.addRecipe(new ItemStack(Item.stick, 4), new Object[]{"W  ","W  ","   ",'W', mod_testmod.candyWood});
		ModLoader.addRecipe(new ItemStack(Item.stick, 4), new Object[]{"  W","  W","   ",'W', mod_testmod.candyWood});
		ModLoader.addRecipe(new ItemStack(Block.chest, 1), new Object[]{"WWW","W W","WWW",'W', mod_testmod.candyWood});
		ModLoader.addRecipe(new ItemStack(Item.pickaxeWood, 1), new Object[]{"WWW"," X "," X ",'W', mod_testmod.candyWood, 'X', Item.stick});
		ModLoader.addRecipe(new ItemStack(Item.axeWood, 1), new Object[]{" WW"," XW"," X ",'W', mod_testmod.candyWood, 'X', Item.stick});
		ModLoader.addRecipe(new ItemStack(Item.axeWood, 1), new Object[]{"WW ","WX "," X ",'W', mod_testmod.candyWood, 'X', Item.stick});
		ModLoader.addRecipe(new ItemStack(Item.axeWood, 1), new Object[]{"WW ","XW ","X  ",'W', mod_testmod.candyWood, 'X', Item.stick});
		ModLoader.addRecipe(new ItemStack(Item.axeWood, 1), new Object[]{" WW"," WX","  X",'W', mod_testmod.candyWood, 'X', Item.stick});
		ModLoader.addRecipe(new ItemStack(Item.hoeWood, 1), new Object[]{" WW"," X "," X ",'W', mod_testmod.candyWood, 'X', Item.stick});
		ModLoader.addRecipe(new ItemStack(Item.hoeWood, 1), new Object[]{"WW "," X "," X ",'W', mod_testmod.candyWood, 'X', Item.stick});
		ModLoader.addRecipe(new ItemStack(Item.hoeWood, 1), new Object[]{"WW ","X  ","X  ",'W', mod_testmod.candyWood, 'X', Item.stick});
		ModLoader.addRecipe(new ItemStack(Item.hoeWood, 1), new Object[]{" WW","  X","  X",'W', mod_testmod.candyWood, 'X', Item.stick});
		ModLoader.addRecipe(new ItemStack(Item.shovelWood, 1), new Object[]{"  W","  X","  X",'W', mod_testmod.candyWood, 'X', Item.stick});
		ModLoader.addRecipe(new ItemStack(Item.shovelWood, 1), new Object[]{" W "," X "," X ",'W', mod_testmod.candyWood, 'X', Item.stick});
		ModLoader.addRecipe(new ItemStack(Item.shovelWood, 1), new Object[]{"W  ","X  ","X  ",'W', mod_testmod.candyWood, 'X', Item.stick});
		ModLoader.addRecipe(new ItemStack(Item.swordWood, 1), new Object[]{"  W","  W","  X",'W', mod_testmod.candyWood, 'X', Item.stick});
		ModLoader.addRecipe(new ItemStack(Item.swordWood, 1), new Object[]{" W "," W "," X ",'W', mod_testmod.candyWood, 'X', Item.stick});
		ModLoader.addRecipe(new ItemStack(Item.swordWood, 1), new Object[]{"W  ","W  ","X  ",'W', mod_testmod.candyWood, 'X', Item.stick});
		ModLoader.addRecipe(new ItemStack(ebonyBoots, 1), new Object[]{"   ","W W","W W",'W', mod_testmod.shardEbony});
		ModLoader.addRecipe(new ItemStack(ebonyBoots, 1), new Object[]{"W W","W W","   ",'W', mod_testmod.shardEbony});
		ModLoader.addRecipe(new ItemStack(ebonyLegs, 1), new Object[]{"WWW","W W","W W",'W', mod_testmod.shardEbony});
		ModLoader.addRecipe(new ItemStack(ebonyPlate, 1), new Object[]{"W W","WWW","WWW",'W', mod_testmod.shardEbony});
		ModLoader.addRecipe(new ItemStack(ebonyMask, 1), new Object[]{"   ","WWW","W W",'W', mod_testmod.shardEbony});
		ModLoader.addRecipe(new ItemStack(ebonyMask, 1), new Object[]{"WWW","W W","   ",'W', mod_testmod.shardEbony});
		ModLoader.addRecipe(new ItemStack(placeHolderII, 1), new Object[]{" W ","WXW"," W ",'W', mod_testmod.shardEbony,'X', Item.enderPearl});
		ModLoader.addShapelessRecipe(new ItemStack(Item.book, 1), new Object[] {leatherPink, Item.paper, Item.paper, Item.paper});
		
		//purple armor
		ItemStack purpleLeatherplate = new ItemStack(Item.plateLeather, 1);
        NBTTagCompound var3 = purpleLeatherplate.getTagCompound();
        ItemStack purpleLeatherhat = new ItemStack(Item.helmetLeather, 1);
        
        ItemStack purpleLeatherboots = new ItemStack(Item.bootsLeather, 1);
       
        ItemStack purpleLeatherlegs = new ItemStack(Item.legsLeather, 1);
        
        if (var3 == null)
        {
            var3 = new NBTTagCompound();
            purpleLeatherplate.setTagCompound(var3);
            purpleLeatherhat.setTagCompound(var3);
            purpleLeatherboots.setTagCompound(var3);
            purpleLeatherlegs.setTagCompound(var3);
        }
        NBTTagCompound var4 = var3.getCompoundTag("display");
        if (!var3.hasKey("display"))
        {
            var3.setCompoundTag("display", var4);
        }
        var4.setInteger("color", 750000000);
        
		ModLoader.addRecipe(purpleLeatherplate, new Object[]{"W W","WWW","WWW",'W', mod_testmod.leatherPink});
		ModLoader.addRecipe(purpleLeatherboots, new Object[]{"W W","W W","   ",'W', mod_testmod.leatherPink});
		ModLoader.addRecipe(purpleLeatherboots, new Object[]{"   ","W W","W W",'W', mod_testmod.leatherPink});
		ModLoader.addRecipe(purpleLeatherlegs, new Object[]{"WWW","W W","W W",'W', mod_testmod.leatherPink});
		ModLoader.addRecipe(purpleLeatherhat, new Object[]{"WWW","W W","   ",'W', mod_testmod.leatherPink});
		ModLoader.addRecipe(purpleLeatherhat, new Object[]{"   ","WWW","W W",'W', mod_testmod.leatherPink});
		
		ModLoader.addShapelessRecipe(new ItemStack(placeHolder, 1), new Object[] {leatherPink, purpleMilk.setContainerItem(Item.bucketEmpty), candyWood});
		
		
		
	}
	public void keyboardEvent(KeyBinding event){
		if (event == this.key_fly){
			fly = !fly;
		}
		if (event == this.key_creep){
			creep = !creep;
		}
	}
	
	public boolean onTickInGame(float par1, net.minecraft.client.Minecraft mc){
		
		PlayerCapabilities pc = ModLoader.getMinecraftInstance().thePlayer.capabilities;
		
		ItemStack boots = mc.thePlayer.inventory.armorInventory[0];
		ItemStack pants = mc.thePlayer.inventory.armorInventory[1];
		ItemStack plate = mc.thePlayer.inventory.armorInventory[2];
		ItemStack hat = mc.thePlayer.inventory.armorInventory[3];
		
		if(fly && toFly == 0 && !mc.thePlayer.onGround && hasFlown == false && boots != null && boots.itemID == mod_testmod.ebonyBoots.itemID){
			pc.isFlying = true;
			toFly = 300;
			hasFlown = true;
		}
		if(toFly > 0){
			--toFly;
		}
		if(toFly == 0 && fly){
			fly = false;
			pc.isFlying = false;
		}
		if(mc.thePlayer.onGround){
			toFly = 0;
			hasFlown = false;
			damageSheild = 120;
		}
		
//		if(fly || damageSheild > 0){
//			mc.thePlayer.fallDistance = 0;
//		}
		if(damageSheild > 0){
			--damageSheild;
		}
		if(pants != null && pants.itemID == mod_testmod.ebonyLegs.itemID && mc.thePlayer.onGround){
			 mc.thePlayer.motionX *= 1.05D;
		     mc.thePlayer.motionZ *= 1.05D;
		}
		if(pants != null && pants.itemID == mod_testmod.ebonyLegs.itemID && !mc.thePlayer.onGround){
			 mc.thePlayer.motionX *= 1.02D;
		     mc.thePlayer.motionZ *= 1.02D;
		}
		if( plate != null && plate.itemID == mod_testmod.ebonyPlate.itemID && wasPlate == 0){
			float xOff = (float) (Math.random() - .5);
			float yOff = (float) (Math.random() - .5);
			float zOff = (float) (Math.random() - .5);
			mc.theWorld.spawnParticle("flame", mc.thePlayer.lastTickPosX + xOff, (mc.thePlayer.lastTickPosY + yOff) - .7, mc.thePlayer.lastTickPosZ + zOff, 0.0D, 0.0D, 0.0D);
			wasPlate = 2;
			
					
		}
		if(wasPlate != 0){
			wasPlate--;
		}
		if( hat != null && hat.itemID == mod_testmod.ebonyMask.itemID && creep){
			mc.thePlayer.playSound("mob.creeper.say", 1, 1);
			
			creep = false;
		}
//		if(plate == null || plate.itemID != mod_testmod.ebonyPlate.itemID && toPotion == 0){
//			if(wasPlate){
//				pc.disableDamage = false;
//				wasPlate = false;
//			}
//		}
		
		return true;
	}
	
	
	public void addRenderer(Map map){
		map.put(EntityPurpleCow.class, new RenderPurpleCow(new ModelCow(), 0.5F));
		map.put(EntityRainbowSheep.class, new RenderRainbowSheep(new ModelRainbowSheep2(), new ModelRainbowSheep1(), 0.5F));
		map.put(NovaBombPrimed.class, new RenderNovaBombPrimed());
	}
	public void generateSurface(World world, Random random, int i, int j){
		for(int k = 0; k < 1; k++){
			int randPosX = i + random.nextInt(16);
			int randPosY = random.nextInt(60);
			int randPosZ = j + random.nextInt(16);
			(new WorldGenMinable(oreEbony.blockID, 1)).generate(world, random, randPosX, randPosY, randPosZ);
			
		}
		BiomeGenBase biome = world.getWorldChunkManager().getBiomeGenAt(i, j);
		WorldGenCandyTrees tree = new WorldGenCandyTrees(true);
		if(biome instanceof CloseLands){
		for(int k = 0; k < 2; k++){
			int randPosX = i + random.nextInt(16);
			int randPosY = world.getHeightValue(i, j);
			int randPosZ = j + random.nextInt(16);
			tree.generate(world, random, randPosX, randPosY, randPosZ);
		}
	}
	}

}
